<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
{{template "common/link.html" .}}
</head>
<body>
<div class="container demo-1">
    <div class="content" style="padding-top: 0px !important;">
        <div id="large-header" class="large-header">
            <canvas id="demo-canvas"></canvas>
            <div class="logo_box">
                <h3>欢迎你</h3>
                <form action="#" name="f" method="post">
                    <div class="input_outer">
                        <span class="u_user"></span>
                        <input name="username" class="text" style="color: #FFFFFF !important" type="text"
                               placeholder="请输入账户">
                    </div>
                    <div class="input_outer">
                        <span class="us_uer"></span>
                        <input name="password" class="text"
                               style="color: #FFFFFF !important; position:absolute; z-index:100;" value=""
                               type="password" placeholder="请输入密码">
                    </div>
                    <div class="mb2"><a id="sub" lay-filter="sub" class="act-but submit" href="javascript:;"
                                        style="color: #FFFFFF">登录</a></div>
                    <div class="mb2"><a id="reg" lay-filter="register" class="act-but register" href="/register"
                                        style="color: #FFFFFF">注册</a></div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- /container -->
</body>
<script src="/static/js/TweenLite.min.js"></script>
<script src="/static/js/EasePack.min.js"></script>
<script src="/static/js/rAF.js"></script>
<script src="/static/js/demo-1.js"></script>
<script>
    //加载弹出层组件
    layui.use('layer', function () {
        var layer = layui.layer;
        //登录的点击事件
        $("#sub").on("click", function () {
            login();
        })

        $("body").keydown(function () {
            if (event.keyCode == "13") {
                login();
            }
        })

        //登录函数
        function login() {
            var username = $(" input[ name='username' ] ").val();
            var password = $(" input[ name='password' ] ").val();
            $.ajax({
                url: "/login",
                data: {"username": username, "password": password},
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        if (data.action) {
                            layer.msg(data.msg);
                            setTimeout(function () {
                                window.location.href = data.action;
                            }, 300)
                        }
                    } else {
                        layer.msg(data.msg);
                    }
                }
            })
        }
    })
</script>
</html>